package com.bestcem.xm.ticket.enums;

import lombok.Getter;

/**
 * 角色状态枚举
 *
 * @author ympan <yuming.pan@idiaoyan.com>
 * @version v1.0
 * @date 2021/8/27 14:14
 */
@Getter
public enum RoleStatusEnum {
    /*
     * 活动的
     */
    ROLE_STATUS_ACTIVATED("ROLE_STATUS_ACTIVATED", 0),

    /*
     * 禁用的
     */
    ROLE_STATUS_INACTIVATED("ROLE_STATUS_INACTIVATED", 1);

    private final String name;

    private final Integer index;

    RoleStatusEnum(String name, Integer index) {
        this.name = name;
        this.index = index;
    }

    /**
     * 根据 index 获取枚举实体
     * 找不到则返回 null
     *
     * @param index 角色状态index
     * @return 角色状态枚举
     * @author <yuming.pan@idiaoyan.com>
     * @date 14:15 2021/8/27
     */
    public static RoleStatusEnum getByIndex(Integer index) {
        for (RoleStatusEnum value : values()) {
            if (value.getIndex().equals(index)) {
                return value;
            }
        }
        return null;
    }
}
